﻿namespace FrameWork.Lib.HTML
{
    using System;
    using System.ComponentModel;

    public class HtmlText : HtmlNode
    {
        protected string mText;

        public HtmlText(string text)
        {
            this.mText = text;
        }

        public override string ToString()
        {
            return this.Text;
        }

        public override string HTML
        {
            get
            {
                if (this.NoEscaping)
                {
                    return this.Text;
                }
                return HtmlEncoder.EncodeValue(this.Text);
            }
        }

        internal bool NoEscaping
        {
            get
            {
                if (base.mParent == null)
                {
                    return false;
                }
                return base.mParent.NoEscaping;
            }
        }

        [Category("General"), Description("The text located in this text node")]
        public string Text
        {
            get
            {
                return this.mText;
            }
            set
            {
                this.mText = value;
            }
        }

        public override string XHTML
        {
            get
            {
                return HtmlEncoder.EncodeValue(this.Text);
            }
        }
    }
}

